package cn.usian.service.impl;

import cn.usian.common.R;
import cn.usian.dao.SetmealDao;
import cn.usian.entity.Dish;
import cn.usian.entity.Employee;
import cn.usian.entity.Setmeal;
import cn.usian.service.SetmealService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Service
public class SetmealServiceImpl implements SetmealService {
    @Resource
    private SetmealDao setmealDao;

    @Override
    public R<Page<Setmeal>> page(Integer page, Integer pageSize, String name) {
        LambdaQueryWrapper<Setmeal> queryWrapper = new LambdaQueryWrapper<>();

        queryWrapper.like(name!=null,Setmeal::getName,name);

        Page<Setmeal> setmealPage = setmealDao.selectPage(new Page<>(page, pageSize), queryWrapper);

        return R.success(setmealPage);
    }

    @Override
    public void del(long[] ids) {
            for (long id : ids) {
                setmealDao.deleteById(id);
            }
    }

    @Override
    public R status(Integer status, long[] ids) {
        Setmeal setmeal=new Setmeal();
        for (long id : ids) {
            setmeal.setId(id);
            setmeal.setStatus(status);
            setmealDao.updateById(setmeal);
        }
        return R.success("修改状态成功");
    }
    }

